import request from '@/api/axios'
import {AxiosPromise} from 'axios'
import {DataRes, Paging} from '@/api/config'

// 科室编码 deptCode
// 科室名称 deptName
// 排序	sort
// 检查类型 checkType checkTypeName

//体检科室分页查询数据定义
export interface GetDepartmentList extends Paging{
  deptName?:string|null,
  deptCode?:string|null,
  checkType?:string|null,
  sort?:string|null,
  checkTypeName?:string|null
}

// 搜索数据定义
export interface SearchDepartmentFromData{
  deptName?:string|null,
  checkType?:string|null,
}

//表头按钮定义
export type TableOperation='add'

// 体检科室基本信息
export interface BaseDepartmentInfor{
  deptName:string,
  deptCode:string,
  sort:string|null,
  checkType:string,
  checkTypeName:string
}

//体检科室信息
export interface DepartmentInfor extends BaseDepartmentInfor{
  id:number
}

export type DepartmentFormInfor = Partial<DepartmentInfor>

export interface DepartmentInforList {
  size:number
  total:number
  records:Array<DepartmentInfor>
}
//获取体检科室管理列表事件
export const getDepartmentList = (params:GetDepartmentList):AxiosPromise<DataRes<DepartmentInforList>> => {
  return request({
    url:'/api/dept/page',
    method:'get',
    params
  })
}

//保存修改体检科室信息事件
export const saveDepartmentInfor = (data:DepartmentFormInfor):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/dept/save',
    method:'post',
    data
  })
}

// 删除体检科室信息事件
export const deleteDepartment = (params:{deptId:string}):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/dept/delete',
    method:'post',
    params
  })
}